﻿function Search(objid) {
    $("#" + objid + "").parents('form')[0].submit()

}
$(function () {

    $('#but_Search').click(function () {

        $(this).parents('form')[0].submit()

    });

    $('#but_back').click(function () {
        window.history.back();
    });

    $('#searchForm').keydown(function () {
        keyDownSearch();

    });
   

})

function keyDownSearch(e) {
    // 兼容FF和IE和Opera  
    var theEvent = e || window.event;
    var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
    if (code == 13) {
        $('#but_Search').click();
        return false;
    }
    return true;
}




function onlyNum() {
//只能输入数字
    if (!(event.keyCode == 46) && !(event.keyCode == 8) && !(event.keyCode == 37) && !(event.keyCode == 39))
        if (!((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105)))
            event.returnValue = false;
}
function openWin(url, iWidth, iHeight) {
   // var url = 'Add.aspx';                             //转向网页的地址; 
    var name = 'add';                            //网页名称，可为空; 
    //var iWidth = 720;                          //弹出窗口的宽度; 
   // var iHeight = 600;                         //弹出窗口的高度; 
    //获得窗口的垂直位置 
    var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
    //获得窗口的水平位置 
    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
    window.open(url, name, 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');
    // window.open("AddScfj.aspx", "newWindows", 'height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no'); 
}

function JSGuid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}




function ConvertJSONDateToJSDate(jsondate) {
    var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10));
    return date;
}
function getDateMinute(date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hh = date.getHours();
    var mm = date.getMinutes();
    var ss = date.getSeconds();

    var monthstr = month.toString();
    if (month < 10) {
        monthstr = "0" + month.toString();
    }
    var daystr = day.toString();
    if (day < 10) {
        daystr = "0" + day.toString();
    }

    var hhstr = hh.toString();
    if (hh < 10) {
        hhstr = "0" + hh.toString();
    }

    var mmstr = mm.toString();
    if (mm < 10) {
        mmstr = "0" + mm.toString();
    }

    return year + "-" + monthstr + "-" + daystr + " " + hhstr + ":" + mmstr;
}
function getDateDay(date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hh = date.getHours();
    var mm = date.getMinutes();
    var ss = date.getSeconds();

    var monthstr = month.toString();
    if (month < 10) {
        monthstr = "0" + month.toString();
    }
    var daystr = day.toString();
    if (day < 10) {
        daystr = "0" + day.toString();
    }

    var hhstr = hh.toString();
    if (hh < 10) {
        hhstr = "0" + hh.toString();
    }

    var mmstr = mm.toString();
    if (mm < 10) {
        mmstr = "0" + mm.toString();
    }

    return year + "-" + monthstr + "-" + daystr;
}





function DateDiff(sDate1, sDate2) {  //sDate1和sDate2是yyyy-MM-dd格式



    var aDate, oDate1, oDate2, iDays;

    aDate = sDate1.split("-");

    oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);  //转换为yyyy-MM-dd格式

    aDate = sDate2.split("-");

    oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]);

    iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24); //把相差的毫秒数转换为天数



    return iDays;  //返回相差天数

}


